/**
 * 设备和人
 */
export default  class MachineEntity {
    constructor(id, name, type, isAvailable) {
        this.id = id;
        this.name = name;
        this.type = type;
        this.isAvailable = isAvailable;
        this.items=new Array();//属性
    }

    process(material, time) {
        return new Promise((resolve, reject) => {
            if (this.isAvailable) {
                console.log(`${this.name} 开始处理材料 ${material.name}`);
                this.isAvailable = false;
                setTimeout(() => {
                    console.log(`${this.name} 完成处理材料 ${material.name}`);
                    this.isAvailable = true;
                    resolve(`${this.name} 完成处理`);
                }, time);
            } else {
                reject(`${this.name} 正在处理其他材料，无法开始新的处理`);
            }
        });
    }
}



